<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //Promise.race()
        const delay = ms => {
            return new Promise(resolve => {
                setTimeout(resolve, ms)
            })
        }

        const p1 = delay(1000).then(() => {
            console.log('p1完成了');
            return 'p1'
                //return Promise.reject('reason')
        })

        const p2 = delay(2000).then(() => {
                console.log('p2完成了');
                //  return 'p2'
                return Promise.reject('reason')
            })
            // Promise.allSettled()的状态与传入的promise状态无关
            //永远都是成功的状态
            //它只会忠实的记录下各个Promise的表现
        const allSettledPromise = Promise.allSettled([p1, p2])
        allSettledPromise.then(data => {
            console.log('succ', data);
        })
    </script>

</body>

</html>